﻿@{
    Layout = null;
}

<link href="~/lib/jquery-ui-min/themes/base/jquery-ui.min.css" rel="stylesheet" />
<link href="~/lib/elFinder/css/elfinder.min.css" rel="stylesheet" />
<link href="~/lib/elFinder/css/theme.css" rel="stylesheet" />

<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/jquery-ui-min/jquery-ui.min.js"></script>
<script src="~/lib/elFinder/js/elfinder.min.js"></script>
<script src="~/lib/elFinder/js/i18n/elfinder.zh_CN.js"></script>

<div id="elfinder"></div>

<script type="text/javascript">
		// Documentation for client options:
		// https://github.com/Studio-42/elFinder/wiki/Client-configuration-options
        $(document).ready(function () {
            var myCommands = elFinder.prototype._options.commands;
            var disabled = ['callback', 'chmod', 'editor', 'netmount', 'ping', 'search', 'zipdl', 'help']; // Not yet implemented commands in elFinder.NetCore
            elFinder.prototype.i18.en.messages.TextArea = "Edit";
            $.each(disabled, function (i, cmd) {
                (idx = $.inArray(cmd, myCommands)) !== -1 && myCommands.splice(idx, 1);
            });
            var options = {
                url: '/el-finder/file-system/connector', // Default (Local File System)
                //url: '/el-finder/azure-storage/connector', // Microsoft Azure Connector
                @*//customData: { folder: '@Model.Folder', subFolder: '@Model.SubFolder' }, // customData passed in every request to the connector as query strings. These values are used in FileController's Index method.*@
                rememberLastDir: false, // Prevent elFinder saving in the Browser LocalStorage the last visited directory
                commands: myCommands,
                //lang: 'pt_BR', // elFinder supports UI and messages localization. Check the folder Content\elfinder\js\i18n for all available languages. Be sure to include the corresponding .js file(s) in the JavaScript bundle.
                uiOptions: { // UI buttons available to the user
                    toolbar: [
                        ['back', 'forward'],
                        ['reload'],
                        ['home', 'up'],
                        ['mkdir', 'mkfile', 'upload'],
                        ['open', 'download'],
                        ['undo', 'redo'],
                        ['info'],
                        ['quicklook'],
                        ['copy', 'cut', 'paste'],
                        ['rm'],
                        ['duplicate', 'rename', 'edit'],
                        ['selectall', 'selectnone', 'selectinvert'],
                        ['view', 'sort']
                    ]
                },
                getFileCallback: function (file, fm) {
                    var fileUrl = '/' + file.path.replace(/\\/g, "/");
                    window.opener.CKEDITOR.tools.callFunction((function () {
                        var reParam = new RegExp('(?:[\?&]|&amp;)CKEditorFuncNum=([^&]+)', 'i');
                        var match = window.location.search.match(reParam);
                        return (match && match.length > 1) ? match[1] : '';
                    })(), fileUrl);

                    fm.destroy();
                    window.close();
                },
                lang: 'zh_CN', // Change language
            };
            $('#elfinder').elfinder(options).elfinder('instance');
        });
</script>
